Ensure env vars are set for cargo-doc
authorAlex Crichton <alex@alexcrichton.com>
Wed, 6 Aug 2014 06:34:55 +0000 (23:34 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 6 Aug 2014 20:21:16 +0000 (13:21 -0700)
This erroneously used util::process instead of the custom process function in
the cargo_rustc module.

src/cargo/core/manifest.rs
src/cargo/ops/cargo_rustc/context.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/util/toml.rs
tests/support/paths.rs
tests/test_cargo_compile_plugins.rs

index e4249ca9c6d0f6ee83b645278c5d946fec20a80c..f31d322c9ae1f38dfb919aa7b15b56b783baed2f 100644 (file)
@@ -109,11 +109,24 @@ pub struct Profile {
     opt_level: uint,
     debug: bool,
     test: bool,
+    doc: bool,
     dest: Option<String>,
     plugin: bool,
 }
 
 impl Profile {
+    fn default() -> Profile {
+        Profile {
+            env: String::new(),
+            opt_level: 0,
+            debug: false,
+            test: false,
+            doc: false,
+            dest: None,
+            plugin: false,
+        }
+    }
+
     pub fn default_dev() -> Profile {
         Profile {
             env: "compile".to_string(), // run in the default environment only
@@ -122,50 +135,45 @@ impl Profile {
             test: false, // whether or not to pass --test
             dest: None,
             plugin: false,
+            doc: false,
         }
     }
 
     pub fn default_test() -> Profile {
         Profile {
-            env: "test".to_string(), // run in the default environment only
-            opt_level: 0,
+            env: "test".to_string(),
             debug: true,
-            test: true, // whether or not to pass --test
+            test: true,
             dest: Some("test".to_string()),
-            plugin: false,
+            .. Profile::default()
         }
     }
 
     pub fn default_bench() -> Profile {
         Profile {
-            env: "bench".to_string(), // run in the default environment only
+            env: "bench".to_string(),
             opt_level: 3,
-            debug: false,
-            test: true, // whether or not to pass --test
+            test: true,
             dest: Some("bench".to_string()),
-            plugin: false,
+            .. Profile::default()
         }
     }
 
     pub fn default_release() -> Profile {
         Profile {
-            env: "release".to_string(), // run in the default environment only
+            env: "release".to_string(),
             opt_level: 3,
-            debug: false,
-            test: false, // whether or not to pass --test
             dest: Some("release".to_string()),
-            plugin: false,
+            .. Profile::default()
         }
     }
 
     pub fn default_doc() -> Profile {
         Profile {
             env: "doc".to_string(),
-            opt_level: 0,
-            debug: false,
-            test: false,
             dest: Some("doc-build".to_string()),
-            plugin: false,
+            doc: true,
+            .. Profile::default()
         }
     }
 
@@ -174,7 +182,7 @@ impl Profile {
     }
 
     pub fn is_doc(&self) -> bool {
-        self.env.as_slice() == "doc"
+        self.doc
     }
 
     pub fn is_test(&self) -> bool {
@@ -216,6 +224,11 @@ impl Profile {
         self
     }
 
+    pub fn doc(mut self, doc: bool) -> Profile {
+        self.doc = doc;
+        self
+    }
+
     pub fn plugin(mut self, plugin: bool) -> Profile {
         self.plugin = plugin;
         self
index 4f86a70b5e83580a5bde58564273f9da7a79f590..95e507075a28c3ef2979af8a7d89a43417f63215 100644 (file)
@@ -227,7 +227,8 @@ impl<'a, 'b> Context<'a, 'b> {
             // doc-all == document everything, so look for doc targets and
             //            compile targets in dependencies
             "doc-all" => target.get_profile().is_compile() ||
-                         target.get_profile().is_doc(),
+                         (target.get_profile().get_env() == "doc" &&
+                          target.get_profile().is_doc()),
             _ => target.get_profile().get_env() == self.env,
         }
     }
index 91c23b77bcb6179c5069f43f1d8e466b866a6761..da46d85cefb126e6a825b30e7a91896e96209332 100644 (file)
@@ -240,7 +240,7 @@ fn rustdoc(package: &Package, target: &Target, cx: &mut Context) -> Work {
     let kind = KindTarget;
     let pkg_root = package.get_root();
     let cx_root = cx.layout(kind).proxy().dest().dir_path().join("doc");
-    let rustdoc = util::process("rustdoc").cwd(pkg_root.clone());
+    let rustdoc = process("rustdoc", package, cx).cwd(pkg_root.clone());
     let rustdoc = rustdoc.arg(target.get_src_path())
                          .arg("-o").arg(cx_root)
                          .arg("--crate-name").arg(target.get_name());
index 22196e6701bc01eee2adf7222de096ec8f818ea7..efce15718867a1ac69f2587981290f34c6053682 100644 (file)
@@ -513,7 +513,10 @@ fn normalize(libs: &[TomlLibTarget],
         }
 
         match dep {
-            Needed => ret.push(Profile::default_test().test(false)),
+            Needed => {
+                ret.push(Profile::default_test().test(false));
+                ret.push(Profile::default_doc().doc(false));
+            }
             _ => {}
         }
 
index 51180e38d7c3befaa2390a3d4ed8ce53dc24de99..b8fd197c506da5efe5265eba5334dbcf8bd592c1 100644 (file)
@@ -75,7 +75,7 @@ impl PathExt for Path {
             let stat = try!(path.stat());
 
             let hour = 1000 * 3600;
-            let mut newtime = stat.modified - hour;
+            let newtime = stat.modified - hour;
             fs::change_file_times(path, newtime, newtime)
         }
     }
index 80e64088bc8ec1f8a5ad0769372e4ec6259f4e71..1b7f7431cad30afd7dbea22bd2648d239429c87d 100644 (file)
@@ -1,4 +1,4 @@
-use support::{project, execs};
+use support::{project, execs, cargo_dir};
 use hamcrest::assert_that;
 
 fn setup() {
@@ -12,14 +12,24 @@ test!(plugin_to_the_max {
             version = "0.0.1"
             authors = []
 
+            [[lib]]
+            name = "foo_lib"
+
             [dependencies.bar]
             path = "../bar"
         "#)
         .file("src/main.rs", r#"
             #![feature(phase)]
             #[phase(plugin)] extern crate bar;
+            extern crate foo_lib;
 
-            fn main() {}
+            fn main() { foo_lib::foo(); }
+        "#)
+        .file("src/foo_lib.rs", r#"
+            #![feature(phase)]
+            #[phase(plugin)] extern crate bar;
+
+            pub fn foo() {}
         "#);
     let bar = project("bar")
         .file("Cargo.toml", r#"
@@ -65,4 +75,6 @@ test!(plugin_to_the_max {
 
     assert_that(foo.cargo_process("cargo-build"),
                 execs().with_status(0));
+    assert_that(foo.process(cargo_dir().join("cargo-doc")),
+                execs().with_status(0));
 })